package com.aaaa.bbbb.service;

import com.aaaa.bbbb.dao.UsersDao;
import com.aaaa.bbbb.domain.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by Administrator on 2020/7/20.
 */

@Service
public class UserService {


    @Autowired
    private UsersDao usersDao;

    public Users login(Users users){

        return usersDao.getUsersByNameAndPassword(users);
    }

    @Transactional(rollbackFor = Exception.class)
    public void tx() throws Exception {
        usersDao.add(new Users(3,"xxx","123"));
        //int i = 1/0;
        usersDao.add(new Users(4,"yyy","123"));

//        int account = 0;
//        if(account<=0){
//            throw  new Exception("账号余额不足");
//        }

    }

}
